package com.core.code;

@SuppressWarnings("unused")
public class ColumnInfo {
	
	private String tableName;// 表格名称
	private String columnName;// 列名称
	private String dataType;// 列数据类型
	private Integer dataPrecision;//数据长度
	private Integer dataScale;//精度
	private String comments;// 字段说明
	private String javaType;// 对应java类型
	
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getColumnName() {
		return columnName;
	}
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}
	public String getDataType() {
		return dataType;
	}
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}
	public Integer getDataPrecision() {
		return dataPrecision;
	}
	public void setDataPrecision(Integer dataPrecision) {
		this.dataPrecision = dataPrecision;
	}
	public Integer getDataScale() {
		return dataScale;
	}
	public void setDataScale(Integer dataScale) {
		this.dataScale = dataScale;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public void setJavaType(String javaType) {
		this.javaType = javaType;
	}
	public String getJavaType() {
		if ("CHAR".equals(dataType)) {
			return "String";
		} else if ("VARCHAR2".equals(dataType)||"VARCHAR".equals(dataType)||"NVARCHAR2".equals(dataType)||"NVARCHAR".equals(dataType)) {
			return "String";
		} else if ("DATE".equals(dataType)) {
			return "Date";
		} else if ("TIMESTAMP(6)".equals(dataType)) {
			return "Date";
		} else if ("TIMESTAMP".equals(dataType)) {
			return "Date";
		}else if ("CLOB".equals(dataType)||"MEDIUMTEXT".equals(dataType)) {
			return "String";
		}  else if ("BLOB".equals(dataType)) {
			return "byte[]";
		} else if ("NUMBER".equals(dataType)||"NUMERIC".equals(dataType)||"INT".equals(dataType)) {
			if(dataScale!=null && dataScale==0){
				if(dataPrecision>9) return "Long";
				return "Integer";
			}else if(dataScale!=0){
				return "Double";
			}
		} else if ("NUMBER1".equals(dataType)) {
			return "Double";
		} else if ("FLOAT".equals(dataType)) {
			return "Double" ;
		}
		return "NoJavaType";
	}
}
